columnview: Take column width into account for measuring
authorMatthias Clasen <mclasen@redhat.com>
Fri, 5 Jun 2020 13:37:59 +0000 (09:37 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 5 Jun 2020 14:42:20 +0000 (10:42 -0400)
When measuring the height of a cell, we need to give
it it the width of its column, if we expect realistic
results.

gtk/gtkcolumnviewcell.c
gtk/gtkcolumnviewtitle.c

index 0f14795476aac6c336ee942effd55f526c7f5d17..e0f08858034f3bd8bc690474cf159bad4be17538 100644 (file)
@@ -55,13 +55,24 @@ gtk_column_view_cell_measure (GtkWidget      *widget,
 {
   GtkColumnViewCell *cell = GTK_COLUMN_VIEW_CELL (widget);
   GtkWidget *child = gtk_widget_get_first_child (widget);
+  int fixed_width = gtk_column_view_column_get_fixed_width (cell->column);
+
+  if (orientation == GTK_ORIENTATION_VERTICAL)
+    {
+      if (fixed_width > -1)
+        {
+          if (for_size == -1)
+            for_size = fixed_width;
+          else
+            for_size = MIN (for_size, fixed_width);
+        }
+    }
 
   if (child)
     gtk_widget_measure (child, orientation, for_size, minimum, natural, minimum_baseline, natural_baseline);
 
   if (orientation == GTK_ORIENTATION_HORIZONTAL)
     {
-      int fixed_width = gtk_column_view_column_get_fixed_width (cell->column);
       if (fixed_width > -1)
         *minimum = *natural = fixed_width;
     }
index 53dc56df8fa34e1e97f8a003f9608ec69d21cd95..12c39d9ba3ca24756b98715466fc55704cdffb92 100644 (file)
@@ -63,13 +63,24 @@ gtk_column_view_title_measure (GtkWidget      *widget,
 {
   GtkColumnViewTitle *self = GTK_COLUMN_VIEW_TITLE (widget);
   GtkWidget *child = gtk_widget_get_first_child (widget);
+  int fixed_width = gtk_column_view_column_get_fixed_width (self->column);
+
+  if (orientation == GTK_ORIENTATION_VERTICAL)
+    {
+      if (fixed_width > -1)
+        {
+          if (for_size == -1)
+            for_size = fixed_width;
+          else
+            for_size = MIN (for_size, fixed_width);
+        }
+    }
 
   if (child)
     gtk_widget_measure (child, orientation, for_size, minimum, natural, minimum_baseline, natural_baseline);
 
   if (orientation == GTK_ORIENTATION_HORIZONTAL)
     {
-      int fixed_width = gtk_column_view_column_get_fixed_width (self->column);
       if (fixed_width > -1)
         *minimum = *natural = fixed_width;
     }